package 种花605;

import java.util.Arrays;

/**
 * ToDo
 *
 * @author: liuzhixin
 * @date: 2021/5/7,8:38
 * @project_name:LeetCode
 */
public class BB {
    public static boolean canPlaceFlowers(int[] flowerbed, int n) {
        int sum =1;
        for(int i =0; i <flowerbed.length; i++ )
        {
            if (flowerbed[i]==0) sum+=1;
            else sum=0;
            if(sum==3)
            {
                n-=1;
                sum=1;
            }
        }
        if(sum==2) n-=1;
        System.out.println(n);
        return n<=0;
    }
    public static void main(String[] args) {
        int[] array = {1,0,0,0,1};
        int n=2;
        Boolean  b = canPlaceFlowers(array, n);
        System.out.println(b);
    }
}
